using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CardManager : MonoBehaviour
{
    public static CardManager Instance;

    public CardDefine[] CardDefines;

    public CharacterCard[] charCards;

    void Awake()
    {
        Instance = this;
    }

    /// <summary>
    /// 洗牌算法
    /// </summary>
    public CardDefine[] Shuffle()
    {
        CardDefine[] cards = new CardDefine[100];
        // 初始化卡牌的数量
        // 60张斩！，20张挡！，20张愈！
        for (int i = 0; i < 60; i++)
        {
            cards[i] = CardDefines[0];
        }
        for (int i = 60; i < 80; i++)
        {
            cards[i] = CardDefines[1];
        }
        for (int i = 80; i < 100; i++)
        {
            cards[i] = CardDefines[2];
        }

        // 洗牌
        for (int i = 0; i < cards.Length; i++)
        {
            CardDefine temp = cards[i];
            // 在i的后面随机一张卡交换
            int index = Random.Range(0, cards.Length);
            cards[i] = cards[index];
            cards[index] = temp;
        }

        return cards;
    }


    /// <summary>
    /// 初始化角色卡（洗牌）
    /// </summary>
    public CharacterCard[] InitCharCard()
    {
        CharacterCard[] cards = new CharacterCard[12];
        for (int i = 0; i < cards.Length; i++)
        {
            CharacterCard temp = cards[i];
            int index = Random.Range(0, cards.Length);
            cards[i] = cards[index];
            cards[index] = temp;
        }

        return cards;
    }
}
